package org.raymond.iworks.study.mq.rabbitmq.rest;

import com.rabbitmq.http.client.Client;
import com.rabbitmq.http.client.ClientParameters;
import lombok.extern.slf4j.Slf4j;

import java.net.MalformedURLException;
import java.net.URISyntaxException;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
@Slf4j
public class RestAPI {
    public static void main(String[] args) throws MalformedURLException, URISyntaxException {
        Client c = new Client(
                new ClientParameters()
                        .url("http://192.168.0.125:15672/api/")
                        .username("admin")
                        .password("admin")
        );
        c.getQueues().stream().forEach(queueInfo -> {
            log.info("name:{}, total:{}, ready:{}, unack:{}", queueInfo.getName(), queueInfo.getTotalMessages(),
                    queueInfo.getMessagesReady(),
                    queueInfo.getMessagesUnacknowledged()
                    );
        });
    }
}
